﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Core.DS
{
    public static partial class classes
    {
        public static dynamic deleteClass(int cid)
        {
            var sql = new Sql.SqlDataContext();
            var c = sql.DSClass.FirstOrDefault(row => row.cid == cid);
            if (c == null) return new
            {
                success = false,
                msg = "班级不存在"
            };
            // Delete Students
            sql.DSClassStudent.DeleteAllOnSubmit(sql.DSClassStudent.Where(row => row.cid == cid));

            // Delete Class
            sql.DSClass.DeleteOnSubmit(c);
            sql.SubmitChanges();
            return new
            {
                success = true
            };
        }
    }
}
